﻿using MultiChoiceVoting.Services;
using Orchard;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Themes;
using System.Web.Mvc;

namespace MultiChoiceVoting.Controllers
{
    [Themed]
    public class VotingController : Controller
    {
        private readonly IOrchardServices _orchardServices;
        private readonly IWorkContextAccessor _wca;
        private readonly IMultiChoiceVotingManager _multiChoceVotingManager;

        public Localizer T { get; set; }
        public ILogger Logger { get; set; }


        public VotingController(
            IOrchardServices orchardServices, 
            IWorkContextAccessor wca, 
            IMultiChoiceVotingManager multiChoceVotingManager)
        {
            _orchardServices = orchardServices;
            _wca = wca;
            _multiChoceVotingManager = multiChoceVotingManager;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }

        public string Vote(int votingId, int answerId)
        {
            // TODO: Use JsonResult
            //var result = Json(_multiChoceVotingManager.Vote(votingId, answerId));
            //return result.ToString();

            return _multiChoceVotingManager.Vote(votingId, answerId);
        }
    }
}